const mysql = require('mysql2')
const MY_SQL_CONFIG = require('./conf/db')

console.log(MY_SQL_CONFIG, '---- process.env.NODE_ENV 04 -----')
const con = mysql.createConnection(MY_SQL_CONFIG)

con.connect((err) => {
  console.log('Connected to MySQL')
})
const addSql = `insert into user(userName,password,state) values('chienli3','123456',1)`
const searchSql = `select id,userName,password,state from user where userName like '%andy%' order by id desc` //倒序模糊查询包含andy的用户
const searchSql2 = `select id,userName,password from user`
const updateSql = `update user set state=0 where userName='andy'`
const deleteSql = `delete from user where id=11`

con.query(searchSql, (err, data) => {
  if (err) throw err
  console.log(data, '----- 查询SQL成功 返回sql数据 -----')
})

con.end()
